package com.datastructure.test.circle;

public class Circle {

    public static void main(String[] args) {

    }

    public int circle (int n) {
        // write code here
        //奇数回不来
        if((n & 1) == 1){
            return 0;
        }
        int e9 = 1000000007;
        //dp[i][j]表示从0出发，走i步到j的方案数
        int[][] dp = new int[++n][11];
        dp[0][0] = 1;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < 10; j++) {
                //前一步走到j旁边的方案数
                if(j == 0){
                    dp[i][j] = (dp[i - 1][9] + dp[i - 1][1]) % e9;
                }else if(j == 9){
                    dp[i][j] = (dp[i - 1][8] + dp[i - 1][0]) % e9;
                }else{
                    dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j + 1]) % e9;
                }
            }
        }
        return dp[--n][0];
    }
}
